<?php
/*
 * MiniMe - a minimalistic OStatus complient microblogging tool
 * Copyright (C) 2010, Tuomas Koski - koski.tuomas@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @author     Tuomas Koski <koski.tuomas@gmail.com>
 * @copyright  Tuomas Koski
 * @license    http://www.gnu.org/licenses/lgpl.txt
 */
$basedir = dirname(__FILE__);
require_once $basedir . '/../../../../classes/minime/pubsubhubbub/minimesubscribers.php';
require_once $basedir . '/../../../../classes/minime/pubsubhubbub/minimesubscriber.php';

class Minime_Pubsubhubbub_MinimeSubscribersTest extends PHPUnit_Framework_TestCase {
    
    public function testConstructorOfMinimePubsubhubbubSubscribersObject() {
        $object = new Minime_Pubsubhubbub_MinimeSubscribers();
        $this->assertEquals("Minime_Pubsubhubbub_MinimeSubscribers", get_class($object));
    }
    
    public function testInitializeSubscribersFromDomElement() {
        $rawXml = '<subscribers>
<subscriber>tkoski</subscriber>
<subscriber>cindy</subscriber>
<subscriber>pamela</subscriber>
</subscribers>
';
        $dom = new DOMDocument();
        $dom->loadXML($rawXml);
        
        $elm = $dom->getElementsByTagName(Minime_Pubsubhubbub_MinimeSubscribers::ELEMENT_SUBSCRIBERS)->item(0);
        $obj = Minime_Pubsubhubbub_MinimeSubscribers::buildFromDom($elm);
        $this->assertEquals("tkoski", $obj->getSubscriber("tkoski")->getID());
        $this->assertEquals("cindy", $obj->getSubscriber("cindy")->getID());
        $this->assertEquals("pamela", $obj->getSubscriber("pamela")->getID());
        $this->assertEquals("tkoski", $obj->getSubscriber("tkoski")->getID());
        $this->assertEquals(3, $obj->lenght());
    }

}